package com.changzhi.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.changzhi.ldyl.model.DressUpGiveConfig;
import com.changzhi.ldyl.model.FirstRechargeRecord;
import com.changzhi.ldyl.model.GiftConfig;
import com.changzhi.ldyl.model.vo.RechargeGiftVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 */
public interface FirstRechargeRecordMapper extends BaseMapper<FirstRechargeRecord> {

    @Select("SELECT giftconf.*,faward.num as gift_num " +
            "FROM yl_firstrecharge_record frecord " +
            "left join yl_firstrecharge_award faward on frecord.id = faward.record_id " +
            "left join yl_gift_config giftconf on giftconf.id = faward.gift_id " +
            "where frecord.id = #{recordId}")
    List<RechargeGiftVo> getFirstRechargeAwardById(@Param("recordId") Integer id);

    @Select("insert into yl_firstrecharge_award(record_id,gift_id,status,create_time,num) select #{recordId},gift_id,0,now(),num from yl_firstrecharge_conf order by order_no")
    void genRechargeGiftAward(@Param("recordId")Integer id);
}
